package com.formula.datastructure.question.tree;

// calculate the depth of tree
public class Quest01 {

    public static void main(String[] args) {

    }
}

class Node01 {
    private Node01 leftChild;
    private Node01 rightChild;

    public int getDepth() {
        if (leftChild == null && rightChild == null) {
            return 1;
        } else {
            int leftDepth = 0;
            int rightDepth = 0;
            if (leftChild != null) {
                leftDepth = leftChild.getDepth();
            }
            if (rightChild != null) {
                rightDepth = rightChild.getDepth();
            }
            // Get the maximum
            return Math.max(leftDepth + 1, rightDepth + 1);
        }
    }
}